home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 44 / Amiga Format CD44 (1999-08-26)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-10].iso / -in_the_mag- / basics / ace / nap.lha / NAP.guide (.txt) < prev    next >
Amigaguide Document  |  1997-05-19  |  20KB  |  495 lines

  1. @database "NAP/NAP.guide"
  2. @master "NAP/NAP.dok"
  3. @node Main "Introduction"
  4. @TOC Inhaltsverzeichnis
  5. @NEXT Aufruf
  6.  @{"NAP - New ACE Preprocessor" link Inhaltsverzeichnis}                              @{"Version 2.02" link History}
  7.  --------------------------                              ------------
  8.  Introduction
  9.  NAP is a preprocessor for the programming language  ACE  (AmigaBASIC
  10.  Compiler with Extras)  by David  Benn.  By  publishing this  version
  11.  there are all in all three preprocessors for ACE:
  12.   (1) APP
  13.       The official preprocessor from the ACE release. It removes ACE
  14.       comments and includes files via @{"#INCLUDE" link Direktiven}.
  15.   (2) ACPP
  16.       The ACE-Version of the C preprocessor CPP.  The only difference
  17.       is that the path for the include files is ACE:. The strength of
  18.       this  preprocessor  is  the  supporting  of  all   preprocessor
  19.       @{"commands" link direktiven}. Furthermore it removes C comments.
  20.   (3) NAP
  21.       This preprocessor is especially for  ACE.  It recognizes almost
  22.       all (inclusive the most important ones)  @{"preprocessor commands" LINK Direktiven},
  23.       removes  ACE  comments as well as  C comments and has even some
  24.       special functions.
  25.                                                       @{"Daniel Seifert" link autor}
  26.                                 Berlin-Hellersdorf, May 19th, 1997
  27. @endnode
  28. @node Inhaltsverzeichnis "AmigaGUIDE Manual for NAP 2.02"
  29. @TOC Inhaltsverzeichnis
  30. @PREV Main
  31. @NEXT Benutzung
  32.  |\   |       |
  33. |       |
  34. |                        Version 2.02
  35.  | \  |       |____|       |____|                         05-19-1997
  36.  |  \ |       |    |       |
  37.  |   \| e w   |    | C E   |     r e p r o c e s s o r
  38.  Table of contents:
  39.  @{"Introduction" link Main}
  40.  @{"How to use" link Benutzung}
  41.  @{"How to start" link Aufruf}
  42.  @{"Options" link Optionen}
  43.  @{"Preprocessor commands" link Direktiven}
  44.  @{"Known bugs" link bugs}
  45.  @{"Future versions" link future}
  46.  @{"Thanks" link greetings}
  47.  @{"Copyright" link Copyright}
  48.  @{"About the autor" link autor}
  49.  @{"History" link history}
  50.  @{"Quit" quit}
  51.  P.S.:
  52.   Actions NAP does and some special things are explained in the corr-
  53.   esponding chapters of @{"OPTIONS" link optionen}
  54. @endnode
  55. @node Escape
  56. @TOC Inhaltsverzeichnis
  57.  Should you have ever the wish  to stop  NAP  you just have to  press
  58.  CTRL-C.
  59. @endnode
  60. @node Benutzung
  61. @TOC Inhaltsverzeichnis
  62. @PREV Inhaltsverzeichnis
  63. @NEXT Aufruf
  64. @TITLE "How to use"
  65.  Copy the new version to ACE:BIN/
  66.  Just replace in your bas script the call of APP or ACPP through NAP.
  67.  The parameters are the same. Should there be options you have to re-
  68.  move them or to replace them by the corresponding @{"ones of NAP" link optionen}.
  69.  If you are using  AIDE  by Herbert Breuer you just have to enter NAP
  70.  in the  "Precompiler" Section under  "other"  and to save the config
  71.  file.
  72. @endnode
  73. @node Aufruf
  74. @TOC Inhaltsverzeichnis
  75. @PREV Benutzung
  76. @NEXT Optionen
  77. @TITLE "How to call"
  78.  You can skip the first paragraph if you are using AIDE:
  79.  NAP can only be launched from the CLI/Shell. It needs a minimum of 2
  80.  parameters: the input and the output file. NAP can't read/write from
  81.  or to standard input/output.
  82.  Pay attention that NAP deletes the output file when it opens it.
  83.  Furthermore you can pass @{"options" link optionen} to NAP.  They must be introduced by
  84.  a hyphen  ("-").  If an option needs an additional parameter it must
  85.  follow  directly  (without spaces)  the corresponding option letter.
  86.  After the parameter there must be a space!
  87.  Of course you can write -tz as well as @{"-t" link OptionT} @{"-z" link OptionZ}.
  88. @endnode
  89. @node Optionen
  90. @TOC Inhaltsverzeichnis
  91. @PREV Aufruf
  92. @NEXT Buffer
  93. @TITLE Options
  94.  Options
  95.   Options are not case sensitive. But be aware that tokens are!
  96.   @{"-b<kB>" link Buffer}                   set buffersize in kilobytes
  97.   @{"-d<token>[<=value>]" link OptionD}      define a token
  98.   @{"-p<path>" link Includepath}                 set path for include files
  99.   @{"-u<token>" link OptionU}                undef a token
  100.   @{"-c" link OptionC}   :   don't remove comments
  101.   @{"-e" link OptionE}   :   suppress error messages
  102.   @{"-h" link OptionH}   :   help
  103.   @{"-i" link OptionI}   :   ignore @{"#Define" link Direktiven}s
  104.   @{"-l" link OptionL}   :   sum empty lines
  105.   @{"-q" link OptionQ}   :   @{"#Define" link Direktiven}s to CONST
  106.   @{"-s" link OptionS}   :   remove unused structs
  107.   @{"-t" link OptionT}   :   tracing
  108.   @{"-x" link OptionX}   :   comment source code
  109.   @{"-z" link OptionZ}   :   elapsed time
  110. @endnode
  111. @node OptionX "-x"
  112. @TOC Inhaltsverzeichnis
  113. @PREV OptionT
  114. @NEXT OptionZ
  115.  NAP now allows you to comment the source code, e.g. it writes single
  116.  line comments ( ' ) into the preprocessed source code  stating which
  117.  line and which  (include) file is processed right now.  This happens
  118.  only if a new file is included.
  119.  These comments are removed properly by the ACE compiler  so there is
  120.  no need to ran  RemoveLine  after it  as it would be necessary  when
  121.  using ACPP.
  122.  This function is useful when ACE reports an error.  And as it is not
  123.  easy to keep track of which part of the preprocessed source code be-
  124.  longs to which file  these comments might help.  But be aware of the
  125.  fact  that the  line numbers may be wrong  as it is count  how  many
  126.  lines are read in but not, how many have been cut (empty lines, pre-
  127.  processor commands, comments, ...).
  128. @endnode
  129. @node Buffer
  130. @TOC Inhaltsverzeichnis
  131. @PREV Optionen
  132. @NEXT OptionD
  133.  To speed NAP up  I wrote a routine which replaces ACE's INPUT# comm-
  134.  and. This routine is much faster due to buffered reading. The buffer
  135.  has a defaultsize of 102400 bytes (100 kB)  and exist for every open
  136.  file.  But the buffer is  never greater  than the file (so we do not
  137.  waste memory)
  138.  Best is if NAP can always write the whole file into the buffer.  100
  139.  kB should be enough for this. But you are allowed to set the buffer-
  140.  size up to a size of 640 kB (this source code I don't want to debug)
  141.  If you do not have enough memory  you  can set the buffer size to  a
  142.  smaller size.
  143. @endnode
  144. @node OptionD "-d<token>[=value]"
  145. @TOC Inhaltsverzeichnis
  146. @PREV Buffer
  147. @NEXT IncludePath
  148.  Same as if you wrote within the source
  149.         @{"#DEFINE" link Direktive} <token> <value>
  150.  If you don't pass <=value>, <value> is 1.
  151. @endnode
  152. @node Includepath "-p<path>"
  153. @TOC Inhaltsverzeichnis
  154. @PREV OptionD
  155. @NEXT OptionU
  156.  Herewith you specify in which path the include files are. Three
  157.  paths are already defined:  ACEINCLUDE:
  158.                              ACE:
  159.                              ACE:INCLUDE/
  160.  I recommened to use always the logical device ACEINCLUDE: !!!
  161. @endnode
  162. @node OptionU "-u<token>"
  163. @TOC Inhaltsverzeichnis
  164. @PREV IncludePath
  165. @NEXT OptionC
  166.  Same as if you wrote within the source
  167.         @{"#UNDEF" link Direktiven} <token>
  168. @endnode
  169. @node OptionC "-c"
  170. @TOC Inhaltsverzeichnis
  171. @PREV OptionU
  172. @NEXT OptionE
  173.  If you use this option  NAP  does not remove comments  but does just
  174.  replace C comments through ACE ones  (so there won't be any problems
  175.  when compiling).
  176. @endnode
  177. @node OptionE "-e"
  178. @TOC Inhaltsverzeichnis
  179. @PREV OptionC
  180. @NEXT OptionH
  181.  By using this option  NAP does suppress  ANY error messages  whether
  182.  they lead to a break  or not  (even "file not found" errors  are not
  183.  printed but be aware of the results when compiling!)
  184. @endnode
  185. @node OptionH "-h"
  186. @TOC Inhaltsverzeichnis
  187. @PREV OptionE
  188. @NEXT OptionI
  189.  Prints a help text.
  190. @endnode
  191. @node OptionI "-i"
  192. @TOC Inhaltsverzeichnis
  193. @PREV OptionH
  194. @NEXT OptionL
  195.  By using this options @{"#DEFINE" LINK Direktiven}s are ignored.
  196. @endnode
  197. @node OptionL "-l"
  198. @TOC Inhaltsverzeichnis
  199. @PREV OptionI
  200. @NEXT OptionQ
  201.  As default NAP does sum up empty lines (real empty lines: lines with
  202.  just one space are not an empty line!). By using this option you are
  203.  telling NAP not to do this anymore!
  204. @endnode
  205. @node OptionQ "-q"
  206. @TOC Inhaltsverzeichnis
  207. @PREV OptionL
  208. @NEXT OptionS
  209.  Defines aren't processed entirely when using this function  but just
  210.  converted to ACE's CONST commands!  Be aware that this may result in
  211.  errors when including files with structures  containing elements ala
  212.  NODEPTR  (#DEFINE NODEPTR ADDRESS)  which will lead  to errors  when
  213.  compiling!
  214.  Pay attention, that you can't pass parameters if you use this option
  215.  to defines!
  216. @endnode
  217. @node OptionS "-s"
  218. @TOC Inhaltsverzeichnis
  219. @PREV OptionQ
  220. @NEXT OptionT
  221.  This option switches on the most interesting function of NAP :-)))))
  222.  NAP does now remove unused structures.
  223.  If you do not understand  why removing of unused structures is good,
  224.  take a look at GadTools.b. Now type
  225.                 ACPP GadTools.b ram:tg_acpp.b <RETURN>
  226.                 NAP -s GadTools.b ram:gt_nap.b <RETURN>
  227.  Recognized? Yeah, gt_na.b is smaller and faster to compile. But why:
  228.  Just type:
  229.                 NAP -st GadTools.b ram:gt_nap.b <RETURN>
  230.  By using option -t you switch on the tracing. At the end of the out-
  231.  put you seen how NAP is listing the structures which are needed and
  232.  which are not.
  233.  As GadTools.b is using dozens of include files there are all at all
  234.  about 110 structures! But not even 20 are needed ...
  235.  And,  by the way,  for people having less memory  removing about 90
  236.  structures is very helpful.
  237. @endnode
  238. @node OptionT "-t"
  239. @TOC Inhaltsverzeichnis
  240. @PREV OptionS
  241. @NEXT OptionX
  242.  Traces the work of NAP (very interesting, just take a look!)
  243.  You get to know:
  244.     - names of the include files, inclusive filenumbers
  245.     - structures (definition, declaration, use) when using @{"-s" Link OptionS}
  246. @endnode
  247. @node OptionT "-z"
  248. @TOC Inhaltsverzeichnis
  249. @PREV OptionX
  250. @NEXT Direktiven
  251.  When using this option NAP will print the time  needed to precompile
  252.  the input file.
  253. @endnode
  254. @node Direktiven
  255. @TOC Inhaltsverzeichnis
  256. @PREV OptionT
  257. @NEXT Bugs
  258.  NAP supports the following commands:
  259.            IF
  260.            IF DEFINED
  261.            IFDEF
  262.            IFNDEF
  263.            ELSE
  264.            ELIF (same as ELSE IF, but NAP does not support ELSE IF!)
  265.            ENDIF
  266.            INCLUDE
  267.            DEFINE
  268.            UNDEF
  269.  Not supported:
  270.            PRAGMA
  271.            ASSERT
  272.            DEBUG
  273.            NODEBUG
  274.            ERROR
  275.  Here a short explanation for the supported ones:
  276.   In general, a preprocessor command is introduced by a # at the very
  277.   beginning of a line. Most commands need an additional parameter.
  278.   -------
  279.   IF <expression>
  280.   <expression>  is a  @{"mathematical term" link mathAusdruck}.  If it's true (not zero) the
  281.   next part (until #ELIF, #ELSE, #ENDIF) will be processed, otherwise
  282.   ignored. IF commands may be nested.
  283.   -------
  284.   IF DEFINED <token> or IFDEF <token>
  285.   Is true, if <token> has been defined.
  286.   -------
  287.   IFNDEF <token>
  288.   Is true, if <token> has NOT been defined.
  289.   -------
  290.   ELSE
  291.   Must follow an  IF or  ELIF command.  The next part is processed if
  292.   the expression at the last IF command has been false. Pay attention
  293.   that there must be only one ELSE command  within an IF command  but
  294.   that NAP does not check!
  295.   -------
  296.   ELIF <expression>
  297.   Combination of "ELSE IF". Pay attention to the fact that ELIF isn't
  298.   implemented very well! Errors when using ELIF are very probable!
  299.   -------
  300.   ENDIF
  301.   Ends an IF command.
  302.   -------
  303.   INCLUDE <filename>
  304.   The < and > MUST really be at the begin and the end of the filename.
  305.   By using this command,  <filename>  is included at this position of
  306.   the file.
  307.   -------
  308.   DEFINE <token> <value>
  309.   Defines <token> as <value>. By writing "#DEFINE one 1" will lead to
  310.   replace "one" by "1" throughout the following part of the source
  311.   code.
  312.   Pay attention that <token> IS case sensitive! "One", "one", "ONE"
  313.   and "oNe" are different tokens!!!
  314.   Of course you can pass parameters. Add to <token> (without spaces!)
  315.   a list of parameters enclosed in brackets and use the same parame-
  316.   ter names within <value>.
  317.   Example:      #DEFINE box(x1,y1,x2,y2) LINE (x1,y1)-(x2,y2),,b
  318.                 box(10,10,100,200)
  319.                 --> LINE (10,10)-(100,200)
  320.   If <value> is very large you may split it in several lines by using
  321.   "\" or "~". This can always be done, not only in #DEFINE.
  322.   Note: When using macros (defines with parameters) be aware that the
  323.         passed parameters between two commas/parantheses MUST NOT be
  324.         any other char than alphanumerical ones!
  325.         =>      box(10, 10, 100, 200)           won't work
  326.         =>      box(1+1,10,100,200)             won't work
  327.         =>      box(getval("x-pos"),10,100,200) won't work
  328.         =>      ...
  329.         This is a bug in the parser routine. It is necessary to re-
  330.         write the whole routine. I'll try to have done it the next
  331.         version.
  332.   -------
  333.   UNDEF <token>
  334.   Undo a DEFINE <token>
  335. @endnode
  336. @node mathAusdruck
  337. @TITLE "Mathematical Expression of the IF and ELIF command"
  338. @TOC Inhaltsverzeichnis
  339. @PREV Direktiven
  340. @NEXT Direktiven
  341.  NAP supports +, -, *, \, / and ().
  342.  The result is always SINGLE!!  Therefore: 1/3 * 3 -1 = -0.000001 in-
  343.  stead of 0 as it would be correct.
  344.  If you want to use hexadecimal numbers or binary numbers use the ACE
  345.  specific prefixes (&H, ...)
  346. @endnode
  347. @node bugs
  348. @TOC Inhaltsverzeichnis
  349. @PREV Direktiven
  350. @NEXT Future
  351. @TITLE "Known bugs"
  352.  * See @{"mathematical expression" link mathAusdruck}
  353.  * ELIF commands are very very buggy! I recommened not to use them.
  354.    Same with ELSE if you use it with ELIF. Otherwise ELSE does work
  355.    correctly.
  356.  * If structures are only refered to via SIZEOF but if they are not
  357.    declared, neither direct nor indirect, NAP removes them.
  358.    HELP: just declare the structure via
  359.                DECLARE STRUCT <struct-name> *dummyptr
  360.  * Some of the include files contain { } statements which are NOT
  361.    comments (C-language's { and } are like PASCALS BEGIN and END!)
  362.    This may cause errors!!!!
  363.    i.e.:  (1)  /*
  364.                #DEFINE InitAnimKey(key) { *(key) = NULL }
  365.                */
  366.                will lead to a single line containing a "}" !!!
  367.                As there is no "{" before ....
  368.           (2)  "#DEFINE testsub { ... }" will lead to "#DEFINE
  369.                testsub "
  370.           (3)  ...
  371.    If you have problems like the above ones you should check the
  372.    include files.
  373.    I just do not have any idea how to fix these problems. Actually
  374.    I don't care about it really as { } ARE comments and this should
  375.    be paid attention to in the include files of ACE. Anyway, per-
  376.    haps replacing { and } by BLOCK and END BLOCK would help ?!
  377.  * Using macros which parameters containing parentheses are passed
  378.    to will cause errors:
  379.      #INCLUDE <ACE/ACEdef.h>
  380.      SetTag(GTLV_Labels,SADD("test"))
  381.    won't be processed correctly. Replacing SADD by @ might help here
  382.    but in general it's a big problem I'll try to fix ASAP.
  383.    Same applies if there's a non-alphanumerical char in the parameter!!!
  384.  If you find more bugs, please contact @{"me" link autor} !!! See @{"History" link history} for already
  385.  removed bugs.
  386. @endnode
  387. @node future
  388. @TOC Inhaltsverzeichnis
  389. @PREV bugs
  390. @NEXT Greetings
  391. @TITLE "Future versions"
  392.  * removing of the @{"bugs" link bugs}
  393.  * more preprocessor commands
  394.  * more options (see ACPP's manual)
  395.  * speed increasing (although NAP has become faster and faster)
  396.  * ...
  397.  Of course I am interested in your ideas.  If  you have some,  please
  398.  contact @{"me" link autor}.       TIA.
  399. @endnode
  400. @node greetings
  401. @TOC Inhaltsverzeichnis
  402. @PREV future
  403. @NEXT Copyright
  404. @TITLE "Thanks and Greetings"
  405.  Thanks to ...
  406.   David Benn,  Author of ACE, for his help and tips for some problems
  407.   as well as for having developed ACE.
  408.   Herbert Breuer for his help at the  assembler routines  and for his
  409.   hints and tips.  Furthermore  thanks  for spending his time testing
  410.   NAP. All found bugs (except the ones I found) are found by him.
  411.   (No wonder  since he is the  one and only user of  NAP.  Or all the
  412.    other ones does not pay attention to the section @{"Coypright" link Copyright} :(
  413.   all the users,  who are going to use NAP and does not pay attention
  414.   to eventual @{"bugs" link bugs}.
  415. @endnode
  416. @node Copyright
  417. @TOC Inhaltsverzeichnis
  418. @PREV Greetings
  419. @NEXT Autor
  420.  NAP - New ACE Preprocessor                              Version 2.02
  421.                                                           05-19-1997
  422.  This version of  NAP as well as the @{"previous ones" link history} are copyright 
  423.  @{"Daniel Seifert" link autor}.
  424.  NAP is Cardware.  This means that the @{"author" link autor} just wants ONE postcard
  425.  from each user (perhaps with an extra beautiful stamp :) and the in-
  426.  formation how the user likes NAP.
  427.  All who do this are allowed to copy and spread NAP (but without ear-
  428.  ning money!). Doing this all files must stay unaltered and together!
  429.  Changes  of  the  source  code are only permissible for the own use.
  430.  Spreading changed versions is NOT allowed!!! (But who thinks to have
  431.  changed/add/improved something important can contact me and I'll see
  432.  to put it in the next version)
  433.  The use of  NAP's sub modules  (especially ones from  NAP_Mods.b) in
  434.  own programs is only allowed  if no  money  is  earned.  Furthermore
  435.  there must be a statement in the source code as well as in the manu-
  436.  al that this routine is  still  copyright  @{"Daniel Seifert" link autor}.  Eventual
  437.  changes must be marked! It would be nice if the one would inform me.
  438.  Since version 2.02 the source code is not longer within the package!
  439.  Disassembling is strongly forbidden.
  440.    Although NAP has been tested there is no warranty that it works
  441.    correctly. You use NAP on your own risk. The author can't be
  442.    made liable for eventual damages.
  443.                                                        Daniel Seifert
  444.                                                          05-19-1997
  445. @endnode
  446. @node Autor
  447. @TOC Inhaltsverzeichnis
  448. @PREV Copyright
  449. @NEXT History
  450. @TITLE Author
  451. My name is Daniel Seifert and I'm born in 1978. At the moment I'm
  452. studying  at  the  "1st  Grammar  School  Hellersdorf"  (Leonard-
  453. Bernstein-Gymnasium) whereas Hellersdorf is the eastermost suburb
  454. of Berlin  which is the capital of Germany, as you probably know,
  455. don't you?
  456. My favourite subjects are Maths, English and,  of course,  compu-
  457. ting.
  458. If you want to contact me, there are three possibilities:
  459.  (a) E-Mail (preferred, except for the picture card! :-)
  460.      You can reach me at my school: dseifert@hell1og.be.schule.de
  461.                                     -----------------------------
  462.      Please  give  me  some  time to answer -> holidays, exams or
  463.      problems with the school computer (no Amiga :(
  464.      After June '98 this EMail address might have gone (hm, well,
  465.      if not I'll have a little problem ;-)  so use the snail mail
  466.      address instead to ask for my  new address  (or look out for
  467.      new programs by me ;-)
  468.      WWW
  469.      Well, as  of  now  I do not have my own home page :-( But if
  470.      you are interested in a (German) math corner, which I helped
  471.      to create, take a look at :
  472.             http://members.aol.com/fuzzymathe/index.htm
  473.  (b) snail mail
  474.      Please do only expect an answer if you enclose  some  money
  475.      for my costs (postage, ...). I am a little bit out of money
  476.      (aren't student always ? ;-)) so I just don't want to spend
  477.      my money on this.
  478.      (Err, I almost forgot my address ;-)
  479.               Daniel Seifert
  480.               Elsenborner Weg 25
  481.               12621 Berlin
  482.               GERMANY
  483.  (c) telephone
  484.      Well, I cannot imagine that anybody wants to contact me
  485.      this way. But anyway: call (+49) 030 5669471 and ask
  486.      for Daniel.                      ^ Berlin
  487.                                  ^ Germany (?)
  488. Happy ACEing ;)
  489. @endnode
  490. @node History
  491. @TOC Inhaltsverzeichnis
  492. @PREV Autor
  493.  See @{"German Manual" link NAP_(d).guide/History}
  494. @endnode
  495.